import {SET_ROUTES, SET_MENU_LIST} from '../actionType'
import { constantRoutes } from "@/router/routes"
import Page404 from '@/pages/Page404'

const initialState = {
  routes: [], // 所有人默认拥有的静态路由
  menuList: [] // 左侧菜单
}

export function permissionReducer(state= initialState, action) {
  const {type, data } = action
  switch(type) {
    case SET_ROUTES:
      return {
        ...state,
        routes: [...constantRoutes, ...data,{path:'*', element:<Page404/>, meta:{hidden:true} }], 
        
      }
    case SET_MENU_LIST: 
      return {
        ...state,
        menuList: [...data]
      }
    default:
      return state
  }
}